package com.coffee.websocket.metadata;

import lombok.Getter;
import lombok.Setter;

import java.nio.ByteBuffer;

/**
 * @author: songkui
 * @since: 2023/3/8 15:31
 */
@Setter
@Getter
public class BitMessage extends MochaBasicBinaryMessage{
    private byte bit = 0;  //占位消息
    private static BitMessage message = new BitMessage();

    private BitMessage(){}
    public static BitMessage build(){
        return message;
    }

    @Override
    public BitMessage decode(ByteBuffer byteBuffer) {
        BitMessage message = new BitMessage();
        message.setBit(byteBuffer.get());
        return message;
    }


    @Override
    public void encode(ByteBuffer byteBuffer) {
        byteBuffer.put((byte) 0);
    }

    @Override
    public int length() {
        return 1;
    }
}
